1. Field of the Invention
The invention relates in general to a data recording method and an apparatus thereof, and more particularly to a data recording method and an apparatus thereof for pseudo-merging at least two files.
2. Description of the Related Art
A multimedia embedded system adopts MPEG-4 video compression technology and 3GPP technology for recording audio/video data and storing multimedia files in a storage medium. The storage space of the embedded system is limited, and the way of recording data greatly influences the size of the storage space and the usage volume of the memory. Therefore, how to record data has become an important issue for the designer/manufacturer of the embedded system.
According to a conventional way for recording data, the video frame and the audio frame are respectively recorded in the video file and the audio file. Meanwhile, the information for each frame is also stored in the memory for recording the sample data of each frame.
When the recording is finished, the video file and the audio file are merged by appending one file to another. First, the content of the audio file is sequentially accessed, and then the accessed audio file is appended to the end of the video file. Besides, when the sample data is converted to and stored in a sample table, the sample table is also appended to the end of the video file.
The storage unit for storing a file is one cluster, and a file is stored in a plurality of clusters. Each of the clusters has 512 bytes. When the size of the stored file is not an integral multiple of 512 bytes, the remnant space called as “hole” would exist at the end of the file. Conventionally, when merging a first file and a second file, the second file is accessed and then recoded in the end of the first file. Therefore, the beginning position for recording the second file is the “hole”. That is to say, the End-Of-File (EOF) of the first file is used as the start point from which the accessed content of the second file is recorded.
According to the conventional way for merging audio and video data, which is implemented by appending one file to another, in the end of a first file, sufficient space has to be reserved for recording a second file. Only after the first and second files have been completely recorded can the second file be accessed and moved to the reserved space so as to be appended to the end of the first file. Therefore, when it is chosen to append an audio file to the end of a video file, in the end of the video file, sufficient space must be reserved for recording the audio file. Similarly, when it is chosen to append a video file to the end of an audio file, in the end of the audio file, sufficient space must be reserved for recording the video file.